package entities;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
public class JeuVideo implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int id;
    private String title;
    private String idYouTubeVideo;
    @Column(length = 20000)
    private String description;
    private String publisher;
    @ManyToOne
    private AgeRating ageRating;
    private double price;
    @Temporal(TemporalType.DATE)
    private Date releaseDate;
    @ManyToOne
    private Categorie categorie;
    @ManyToMany
    private Collection<Tag> tags;
    @OneToOne
    private ImagesGroup image; // Principale
    @OneToMany
    private Collection<ImagesGroup> images; // Diverses
    @OneToMany
    private Collection<Fonctionnalite> fonctionnalites;
    @OneToMany
    private Collection<Comment> commentaires;
    
    public JeuVideo() {
        tags = new ArrayList<Tag>();
        images = new ArrayList<ImagesGroup>();
        fonctionnalites = new ArrayList<Fonctionnalite>();
        commentaires = new ArrayList<Comment>();
    }

    public JeuVideo(String title, Categorie categorie) {
        this.title = title;
        this.categorie = categorie;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public Date getReleaseDate() {
        return releaseDate;
    }

    public Collection<Comment> getCommentaires() {
        return commentaires;
    }

    public void setCommentaires(Collection<Comment> commentaires) {
        this.commentaires = commentaires;
    }

    public void setReleaseDate(Date releaseDate) {
        this.releaseDate = releaseDate;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Categorie getCategorie() {
        return categorie;
    }

    public void setCategorie(Categorie categorie) {
        this.categorie = categorie;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Collection<Tag> getTags() {
        return tags;
    }

    public void setTags(Collection<Tag> tags) {
        this.tags = tags;
    }

    public ImagesGroup getImage() {
        return image;
    }

    public void setImage(ImagesGroup image) {
        this.image = image;
    }

    public Collection<ImagesGroup> getImages() {
        return images;
    }

    public void setImages(Collection<ImagesGroup> images) {
        this.images = images;
    }

    public Collection<Fonctionnalite> getFonctionnalites() {
        return fonctionnalites;
    }

    public void setFonctionnalites(Collection<Fonctionnalite> fonctionnalites) {
        this.fonctionnalites = fonctionnalites;
    }

    public String getPublisher() {
        return publisher;
    }

    public void setPublisher(String publisher) {
        this.publisher = publisher;
    }

    public AgeRating getAgeRating() {
        return ageRating;
    }

    public void setAgeRating(AgeRating ageRating) {
        this.ageRating = ageRating;
    }

    public String getIdYouTubeVideo() {
        return idYouTubeVideo;
    }

    public void setIdYouTubeVideo(String idYouTubeVideo) {
        this.idYouTubeVideo = idYouTubeVideo;
    }


    @Override
    public int hashCode() {
        return id;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof JeuVideo)) {
            return false;
        }
        JeuVideo other = (JeuVideo) object;
        if (this.id != other.id) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "modele.JeuVideo[id=" + id + "]";
    }
}
